package com.hnqcgc.dllShopping.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MyDb implements IDb {
    private  final String URL ="jdbc:mysql://localhost:3306/dujiaoshou?useSSL=false&serverTimezone=Hongkong&characterEncoding=utf-8&autoReconnect=true";
    private  final String USENAME = "root";
    private  final String PASSWORD ="123456" ;

    public MyDb(){
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }
    }
    @Override
    public Connection getConn() throws SQLException {
        Connection conn = DriverManager.getConnection(URL, USENAME, PASSWORD);
        return conn;
    }

    public static void main(String[] args) {
try {
    Connection conn = new MyDb().getConn();
} catch (SQLException throwables) {
    throwables.printStackTrace();

}
    }
}
